<template>
  <view :style="themeColor">
    <view class="page">
      <view class="flex benben-position-layout flex flex-wrap align-center chooseaddress_flex_0"
        :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex flex-wrap align-center justify-between flex-sub chooseaddress_fd0_0'>
          <view class='flex flex-wrap align-center chooseaddress_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
            data-url="1">
            <text class='fu-iconfont2  chooseaddress_fd0_0_c0_c0'>&#xE794;</text>
          </view>
          <view class='flex flex-wrap align-stretch justify-center'>
            <text class='chooseaddress_fd0_0_c1_c0'>工作地点</text>
          </view>
          <view class='flex flex-wrap align-center justify-end chooseaddress_fd0_0_c0' @click.stop="submit">
            <text class='chooseaddress_fd0_0_c2_c0'>确定</text>
          </view>
        </view>

      </view>
      <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout">
        <view class='flex flex-direction flex-wrap align-stretch flex-sub chooseaddress_fd1_0'>
          <text class="text-red text-weight-600 text-lg">可多选</text>
          <view class='flex flex-wrap align-center'>
            <view class='flex flex-wrap align-center chooseaddress_fd1_0_c1_c0' v-for="(itemD,indexD) in chooseArr"
              :key="indexD">
              <text>{{itemD.pname}}</text>
              <image class='chooseaddress_fd1_0_c1_c0_c1' @click.stop="delArr(itemD,indexD)" mode=" aspectFit"
                :src='STATIC_URL+"153.png"'>
              </image>
            </view>
          </view>
        </view>
        <view class="flex">
          <view class="names" v-for="(item,index) in postcate" :key="index" @click.stop="chooseA(item)">{{item.name}}
            <view class="line" v-if="postcateId==item.aid"></view>
          </view>
        </view>
        <view class="flex text-df container">
          <view class="contianer-left-box">
            <view class=" flex align-center justify-center container-left" :class="bigId==itemA.aid?'active' : ''"
              v-for="(itemA,indexA) in postcateC" :key="indexA" @click="choosebig(itemA)">
              <view class="circle" v-if="bigId==itemA.aid"></view>
              <view class="text-cut">{{itemA.name}}</view>

            </view>
          </view>
          <view class="container-box">
            <view class="flex justify-between container-right" v-for="(itemC,indexC) in postcateD" :key="indexC"
              @click="chooseLittle(itemC)">
              <view class="container-name">{{itemC.name}}</view>
              <view class="check-box">
                <image v-if="itemC.check" class='choosework_fd1_1_c0_c1_c0' mode="aspectFit"
                  :src='STATIC_URL+"155.png"'></image>
                <image v-else class='choosework_fd1_1_c0_c1_c0' mode="aspectFit" :src='STATIC_URL+"154.png"'></image>
              </view>

            </view>
          </view>

        </view>

      </view>

      <!---flex布局flex布局结束-->


    </view>
  </view>
</template>
<script>
  export default {
    components: {},


    data() {
      return {
        postcate: [],
        postcateId: '',
        postcateC: [],
        bigId: '',
        postcateD: [],
        bigName: '',
        chooseArr: []
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },

    },
    watch: {},
    onLoad(options) {
      this.getData()
    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {

    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      chooseA(item) {
        this.postcateId = item.aid
        console.log(this.chooseArr, 'chooseArr')
        this.$api.post(global.apiUrls.post65d30c058d328, {
          pid: this.postcateId
        }).then(res => {
          if (res.data.code == 1) {
            this.postcateC = res.data.data
          }
        })
      },
      choosebig(itemA) {
        this.bigId = itemA.aid
        this.bigName = itemA.name
        if (this.bigId != 4) {
          this.chooseArr = [
            itemA
          ]
        } else {
          this.chooseArr = []
        }
        console.log('ppp', itemA, this.chooseArr)
        this.$api.post(global.apiUrls.post65d30c058d328, {
          pid: this.bigId
        }).then(res => {
          if (res.data.code == 1) {
            this.postcateD = res.data.data
          }
        })
      },
      chooseLittle(item, index) {
        item.check = !item.check
        if (item.check) {
          this.chooseArr.push(item)
        } else {
          this.chooseArr.splice(index, 1)
        }

      },
      delArr(item, index) {
        this.chooseArr.splice(index, 1)
      },
      submit() {
        if (this.chooseArr.length == 0) {
          this.$message.info('请选择工作地点')
          return
        }
        uni.$emit('workplace', this.chooseArr)
        uni.navigateBack()
      },
      getData() {
        this.$api.post(global.apiUrls.post65d30c058d328).then(res => {
          if (res.data.code == 1) {
            this.postcate = res.data.data
            this.postcateId = this.postcate[0].aid
            this.$api.post(global.apiUrls.post65d30c058d328, {
              pid: this.postcateId
            }).then(res => {
              if (res.data.code == 1) {
                this.postcateC = res.data.data
              }
            })
          }
        })
      }
    }
  };
</script>
<style lang="scss" scoped>
  .names {
    height: 100rpx;
    line-height: 100rpx;
    width: 25%;
    text-align: center;
    position: relative;

    .line {
      width: 70rpx;
      height: 6rpx;
      border-radius: 16rpx;
      position: absolute;
      bottom: 15%;
      left: 30%;
      background-color: var(--benbenFontColor4);
    }
  }

  .container {
    width: 750rpx;
    height: 80vh;
    padding-bottom: 250rpx;
    font-size: 32rpx;

    // overflow-y: scroll;
    .contianer-left-box {
      height: 75vh;
      overflow-y: scroll;
      background-color: #F8F8F8;
    }

    .container-left {
      width: 250rpx;
      height: 95rpx;
      text-align: center;
      line-height: 95rpx;
      color: #111111;
      // position: relative;

      .circle {
        background-color: #3A87F9;
        width: 6rpx;
        height: 30rpx;
        // position: absolute;
        // top: 24rpx;
        // left: 32rpx;
        margin-right: 10rpx;
        border-radius: 20rpx;
      }

      &.active {
        color: #3A87F9;
        background: #FFF;
      }
    }

    .container-box {
      width: 450rpx;
      height: 80vh;
      overflow-y: scroll;

      .container-right {
        width: 450rpx;
        height: 95rpx;
        line-height: 95rpx;

        .check-box {
          width: 36rpx;
          height: 36rpx;

          image {
            width: 100%;
            height: 100%;
          }
        }

        .container-name {
          color: #A198B4;
          margin-left: 32rpx;

          &.active {
            color: #FFF;
          }
        }

        &.active {

          background: #332949;
        }
      }
    }

  }

  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: var(--benbenbgColor1);
    background-size: 100% auto;
  }

  .chooseaddress_flex_0 {
    background: #fff;
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .chooseaddress_fd0_0_c2_c0 {
    color: var(--benbenFontColor4);
  }

  .chooseaddress_fd0_0_c1_c0 {
    font-size: 36rpx;
    font-weight: 700;
    color: #333333;
    line-height: 50rpx;
  }

  .chooseaddress_fd0_0_c0_c0 {
    font-size: 36rpx;
    color: #333;
  }

  .chooseaddress_fd0_0_c0 {
    width: 120rpx;
  }

  .chooseaddress_fd0_0 {
    padding: 0rpx 32rpx 0rpx 32rpx;
  }

  .chooseaddress_fd1_1_c0_c1_c0 {
    width: 36rpx;
    height: 36rpx;
  }

  .chooseaddress_fd1_1_c0 {
    padding: 24rpx;
  }

  .chooseaddress_fd1_0_c1_c0_c1 {
    width: 32rpx;
    height: 32rpx;
    position: absolute;
    top: -10rpx;
    right: -20rpx;
  }

  .chooseaddress_fd1_0_c1_c0 {
    border: 1px solid var(--benbenbdColor1);
    background: rgba(250, 250, 250, 1);
    background-size: 100% auto;
    padding: 10rpx;
    border-radius: 44rpx;
    margin: 24rpx 12rpx 0rpx 0rpx;
    position: relative;
  }

  .chooseaddress_fd1_0 {
    background: rgba(246, 247, 249, 1);
    background-size: 100% auto;
    padding: 24rpx;
  }
</style>
